import Vue from 'vue'
import Vuex from 'vuex'
import * as actions from './actions'
import * as getters from './getters'
import state from './state'
import mutations from './mutations'
import createLogger from 'vuex/dist/logger'
import cateModule from '@/views/cate/store'
import commentModule from '@/views/comment/store'
import tagModule from '@/views/tag/store'
import topicModule from '@/views/topic/store'
import userModule from '@/views/user/store'
import loginModule from '@/views/login/store'
import linkModule from '@/views/link/store'
import bannerModule from '@/views/banner/store'
import logModule from '@/views/log/store'
import projectModule from '@/views/project/store'
import settingModule from '@/views/setting/store'
import attachmentsModule from '@/components/common/attachments/store'
import musicModule from '@/views/music/store'
import playerModule from '@/components/player/store'
import bookModule from '@/views/book/store'

Vue.use(Vuex)

const debug = process.env.NODE_ENV !== 'production'

export const createStore = () => new Vuex.Store({
  actions,
  getters,
  state,
  mutations,
  strict: debug,
  plugins: debug ? [createLogger()] : [],
  modules: {
    cate: cateModule,
    comment: commentModule,
    tag: tagModule,
    topic: topicModule,
    user: userModule,
    login: loginModule,
    link: linkModule,
    banner: bannerModule,
    log: logModule,
    project: projectModule,
    setting: settingModule,
    attachments: attachmentsModule,
    music: musicModule,
    player: playerModule,
    book: bookModule
  }
})
